import argparse
import sys

import command
import constants
import maven_cmd


def mvn_tree():
    cmd = maven_cmd.get_command_line()
    parser = argparse.ArgumentParser(description='maven 分析包依赖')
    parser.add_argument('-a', '--artifactId', nargs='?', default='', help='包')
    args, unknown_args = parser.parse_known_args()
    artifact_id = args.artifactId
    if len(artifact_id.strip()) == 0 and len(unknown_args) > 0:
        artifact_id = unknown_args[0]
    if len(artifact_id.strip()) == 0:
        print("请输入: 包名")
        sys.exit()
    command_line = constants.MAVEN_TREE.format(cmd, artifact_id)
    command.exe_command(command_line)


if __name__ == '__main__':
    mvn_tree()
